home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / src / config / autoconf next >
Encoding:
Text File  |  1997-08-18  |  7.4 KB  |  273 lines  |  [TEXT/R*ch]

  1. #!/bin/sh
  2.  
  3. case $1 in
  4.   "") cc=cc;;
  5.    *) cc=$1;;
  6. esac
  7. export cc
  8.  
  9. cd auto-aux
  10. rm -f s.h m.h
  11.  
  12. # Check the sizes of data types
  13.  
  14. echo "Checking the sizes of integers and pointers..."
  15. set - `sh runtest sizes.c`
  16. case "$1,$2,$3" in
  17.   4,4,4) echo "OK, this is a regular 32 bit architecture.";;
  18.   4,8,8) echo "Wow! A 64 bit architecture!"
  19.          echo "#define SIXTYFOUR" >> m.h;;
  20.   8,8,8) echo "Wow! A 64 bit architecture!"
  21.          echo "Unfortunately, Caml Light has never been tested in the case"
  22.          echo "sizeof(int) = 8."
  23.          echo "Caml Light won't run on this architecture."
  24.          exit 2;;
  25.   4,4,8) echo "Wow! A 64 bit architecture!"
  26.          echo "Unfortunately, Caml Light cannot work in the case"
  27.          echo "sizeof(long) != sizeof(long *)."
  28.          echo "Caml Light won't run on this architecture."
  29.          exit 2;;
  30.       *) echo "This architecture seems to be neither 32 bits nor 64 bits."
  31.          echo "Caml Light won't run on this architecture."
  32.          exit 2;;
  33. esac
  34.  
  35. # Are chars signed?
  36.  
  37. sh runtest schar.c
  38. case $? in
  39.   0) echo "The char type is signed. Good!";;
  40.   1) echo "The char type is not signed. Let's see if 'signed char' works."
  41.      sh runtest schar2.c
  42.      case $? in
  43.       0) echo "Yes, it works. Good!"
  44.          echo "#define SIGNED_CHAR_WORKS" >> s.h;;
  45.       *) echo "No, it does not work. Let's try some compiler options."
  46.          goodopt=""
  47.          for option in -signed -fsigned-char; do
  48.            sh runtest $option schar.c
  49.            case $? in
  50.              0) goodopt=$option; break;;
  51.            esac
  52.          done
  53.          case "$goodopt" in
  54.            "") echo "Sorry, I can't find the right option."
  55.                echo "Please figure it out yourself, and"
  56.                echo "add it to OTHEROPTS in src/runtime/Makefile.";;
  57.             *) echo "Yippie! Option $goodopt works. Good!"
  58.                echo "Add \"$goodopt\" to OTHEROPTS in src/runtime/Makefile.";;
  59.          esac;;
  60.      esac;;
  61. esac
  62.  
  63. # Determine endianness
  64.  
  65. sh runtest endian.c
  66. case $? in
  67.   0) echo "This is a big-endian architecture."
  68.      echo "#define MOSML_BIG_ENDIAN" >> m.h;;
  69.   1) echo "This is a little-endian architecture."
  70.      echo "#undef MOSML_BIG_ENDIAN" >> m.h;;
  71.   2) echo "This architecture seems to be neither big endian nor little endian."
  72.      echo "Caml Light won't run on this architecture."
  73.      exit 2;;
  74.   *) echo "Something went wrong during endianness determination."
  75.      echo "You'll have to figure out endianness yourself"
  76.      echo "(option MOSML_BIG_ENDIAN in m.h).";;
  77. esac
  78.  
  79. # Determine alignment constraints
  80.  
  81. volatile=""
  82. while true; do
  83.   sh runtest $volatile align.c
  84.   case $? in
  85.   100) echo "Your compiler chokes on the \"volatile\" modifier."
  86.        echo "Never mind, we'll do without it."
  87.        volatile="-Dvolatile=";;
  88.     0) echo "This architecture has no alignment constraints."
  89.        echo "#undef ALIGNMENT" >> m.h
  90.        break;;
  91.     1) echo "This architecture has alignment constraints."
  92.        echo "#define ALIGNMENT" >> m.h
  93.        break;;
  94.     *) echo "Something went wrong during alignment determination."
  95.        echo "I'm going to assume this architecture has alignment constraints."
  96.        echo "That's a safe bet: Caml Light will work even if it turns out that"
  97.        echo "this architecture actually has no alignment constraints."
  98.        echo "#define ALIGNMENT" >> m.h
  99.        break;;
  100.   esac
  101. done
  102.  
  103. sh runtest dblalign.c
  104. case $? in
  105.   0) echo "Doubles can be word-aligned.";;
  106.   1) echo "Doubles must be doubleword-aligned."
  107.      echo "#define ALIGN_DOUBLE" >> m.h;;
  108.   *) echo "Something went wrong during alignment determination for doubles."
  109.      echo "I'm going to assume this architecture has alignment constraints over doubles."
  110.      echo "That's a safe bet: Caml Light will work even if it turns out that"
  111.      echo "this architecture actually has no alignment constraints."
  112.      echo "#define ALIGN_DOUBLE" >> m.h;;
  113. esac
  114.  
  115. # To find a good byte copy function
  116.  
  117. if sh runtest -Dcopy=memmove -Dreverse bytecopy.c; then
  118.   echo "Function \"memmove\" is provided and handles overlapping moves correctly."
  119.   echo "#define HAS_MEMMOVE" >> s.h
  120. fi
  121. if sh runtest -Dcopy=bcopy bytecopy.c; then
  122.   echo "Function \"bcopy\" is provided and handles overlapping moves correctly."
  123.   echo "#define HAS_BCOPY" >> s.h
  124. fi
  125. if sh runtest -Dcopy=memcpy -Dreverse bytecopy.c; then
  126.   echo "Function \"memcpy\" is provided and handles overlapping moves correctly."
  127.   echo "#define HAS_MEMCPY" >> s.h
  128. fi
  129.  
  130. # Check for _longjmp and _setjmp
  131.  
  132. sh runtest setjmp.c
  133. case $? in
  134.   0) echo "_setjmp and _longjmp appear to work. Good!"
  135.      echo "#define HAS__SETJMP" >> s.h;;
  136.   *) echo "No _setjmp, _longjmp. We'll use setjmp and longjmp instead."
  137. esac
  138.  
  139. # Try to find the type of signal handlers
  140.  
  141. h=""
  142.  
  143. for ty in void int; do
  144.   rm -f /tmp/output$$
  145.   if $cc -c -DSIGRETURN=$ty sighandler.c 2>/tmp/output$$; then
  146.     if grep -s -i warning /tmp/output$$; then
  147.       :
  148.     else
  149.       h=$ty
  150.       break
  151.     fi
  152.   fi
  153. done
  154. rm -f sighandler.o
  155.  
  156. case "$h" in
  157.   "") echo "Sorry, I can't determine the return type for signal handlers."
  158.       echo "I'm assuming \"void\". If this seems to cause errors,"
  159.       echo "try to change \"sighandler_return_type\" in s.h"
  160.       h=void;;
  161.    *) echo "The return type for signal handlers appears to be \"$h\".";;
  162. esac
  163. echo "#define sighandler_return_type $h" >> s.h
  164.  
  165. # Check the semantics of signal handlers
  166.  
  167. if sh runtest signals.c; then
  168.   echo "Signals have the BSD semantics."
  169.   echo "#define BSD_SIGNALS" >> s.h
  170. else
  171.   echo "Signals have the System V semantics."
  172. fi
  173.  
  174. # For the sys module
  175.  
  176. if sh hasgot rename; then
  177.   echo "rename() found."
  178.   echo "#define HAS_RENAME" >> s.h
  179. fi
  180.  
  181. # For the Unix library
  182.  
  183. if sh hasgot socket socketpair bind listen accept connect; then
  184.   echo "You have BSD sockets."
  185.   echo "#define HAS_SOCKETS" >> s.h
  186. fi
  187.  
  188. if test -f /usr/include/unistd.h; then
  189.   echo "unistd.h found."
  190.   echo "#define HAS_UNISTD" >> s.h
  191. fi
  192.  
  193. if test -f /usr/include/dirent.h; then
  194.   echo "dirent.h found."
  195.   echo "#define HAS_DIRENT" >> s.h
  196. fi
  197.  
  198. if sh hasgot lockf; then
  199.   echo "lockf() found."
  200.   echo "#define HAS_LOCKF" >> s.h
  201. fi
  202.  
  203. if sh hasgot mkfifo; then
  204.   echo "mkfifo() found."
  205.   echo "#define HAS_MKFIFO" >> s.h
  206. fi
  207.  
  208. if sh hasgot getpriority setpriority; then
  209.   echo "getpriority() found."
  210.   echo "#define HAS_GETPRIORITY" >> s.h
  211. fi
  212.  
  213. if test -f /usr/include/utime.h && sh hasgot utime; then
  214.   echo "utime() found."
  215.   echo "#define HAS_UTIME" >> s.h
  216. fi
  217.  
  218. if sh hasgot utimes; then
  219.   echo "utimes() found."
  220.   echo "#define HAS_UTIMES" >> s.h
  221. fi
  222.  
  223. if sh hasgot dup2; then
  224.   echo "dup2() found."
  225.   echo "#define HAS_DUP2" >> s.h
  226. fi
  227.  
  228. if sh hasgot fchmod fchown; then
  229.   echo "fchmod() found."
  230.   echo "#define HAS_FCHMOD" >> s.h
  231. fi
  232.  
  233. if sh hasgot truncate ftruncate; then
  234.   echo "truncate() found."
  235.   echo "#define HAS_TRUNCATE" >> s.h
  236. fi
  237.  
  238. if sh hasgot select; then
  239.   echo "select() found."
  240.   echo "#define HAS_SELECT" >> s.h
  241. fi
  242.  
  243. if sh hasgot symlink readlink lstat;  then
  244.   echo "symlink() found."
  245.   echo "#define HAS_SYMLINK" >> s.h
  246. fi
  247.  
  248. if sh hasgot wait3;  then
  249.   echo "wait3() found."
  250.   echo "#define HAS_WAIT3" >> s.h
  251. fi
  252.  
  253. if sh hasgot waitpid;  then
  254.   echo "waitpid() found."
  255.   echo "#define HAS_WAITPID" >> s.h
  256. fi
  257.  
  258. if sh hasgot getgroups && test -f /usr/include/sys/param.h && grep -s NGROUPS /usr/include/sys/param.h >/dev/null;
  259. then
  260.   echo "getgroups() found."
  261.   echo "#define HAS_GETGROUPS" >> s.h
  262. fi
  263.  
  264. if test -f /usr/include/termios.h && 
  265.    sh hasgot tcgetattr tcsetattr tcsendbreak tcflush tcflow; then
  266.   echo "POSIX termios found."
  267.   echo "#define HAS_TERMIOS" >> s.h
  268. fi
  269.  
  270. rm -f tst
  271. rm -f ../m.h ../s.h
  272. mv m.h s.h ..
  273.